import {reqDetailListInfo} from '@/api'

const state = {
    detailListInfo: {}
}
const mutations = {
    RECEIVE_DETAILLISTINFO(state, detailListInfo) {
        state.detailListInfo = detailListInfo
    }
}
const actions = {
    async getDetailListInfo({commit}, skuId) {
        const result = await reqDetailListInfo(skuId)
        if (result.code === 200) {
            commit('RECEIVE_DETAILLISTINFO', result.data)
        }
    }
}
const getters = {
    categoryView(state) {
        return state.detailListInfo.categoryView || {}
    },
    skuInfo(state) {
        return state.detailListInfo.skuInfo || {}
    },
    spuSaleAttrList(state) {
        return state.detailListInfo.spuSaleAttrList || []
    }
}
export default {
    state,
    mutations,
    actions,
    getters
}